package org.looop.chuck.persistence.impl;

import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
import java.util.concurrent.ConcurrentHashMap;

import org.looop.chuck.domain.AppInfo;

public class MemoryPersistenceManager extends FileAppInfoWriter {
	private ConcurrentHashMap<String, AppInfo> memStorage = new ConcurrentHashMap<String, AppInfo>();
	public MemoryPersistenceManager(String filePath, String charset)
			throws UnsupportedEncodingException, FileNotFoundException {
		super(filePath, charset);
	}
	
	@Override
	protected int writeApp(AppInfo appInfo) {
		int count = super.writeApp(appInfo);
		memStorage.put(appInfo.getName(), appInfo);
		return count;
	}

	public ConcurrentHashMap<String, AppInfo> getMemStorage() {
		return memStorage;
	}	
	
}
